home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performDetachPreset.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.7 KB  |  156 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar 14, 1997
  22. //  Author:         ms
  23. //
  24. //  Description:
  25. //      This script defines detach on an active list
  26. //
  27.  
  28. proc performDetachPresetSurfaces( int $history,
  29.                                   int $rpo,
  30.                                   string $surfaces[],
  31.                                   string $results[] )
  32. {
  33.     global int $gSelectNurbsSurfacesBit;
  34.  
  35.     string $cmd = "detachSurface" + " -ch " + $history +
  36.         " -rpo " + $rpo + " ";
  37.  
  38.     string $results[];
  39.     string $detachResults[];
  40.  
  41.     // for each string returned from groupObjectsByName, execute the command
  42.     //
  43.     string $groupStrings[];
  44.     $groupStrings = groupObjectsByName( $surfaces, "\\[" );
  45.     int $numStrings = size( $groupStrings );
  46.  
  47.     for( $i = 0; $i < $numStrings; $i ++ ) {
  48.         // execute $cmd + $groupStrings[$i]    
  49.         if( catch( $detachResults = evalEcho( $cmd + $groupStrings[$i]))) {
  50.             warning(" Problem evaluating detach command: " + $cmd + $groupStrings[$i]);
  51.         }
  52.         else {
  53.             int $j;
  54.             int $numResults = size( $results );
  55.             int $numDetachResults = size( $detachResults );
  56.             for( $j = 0; $j < $numDetachResults; $j ++, $numResults ++ ) {
  57.                 $results[$numResults] = $detachResults[$j];
  58.             }
  59.         }
  60.     }
  61.  
  62.     if( 0 == size($results) ) {
  63.         error ("Detach: failed on the input surfaces.");
  64.     }
  65. }
  66.  
  67. proc performDetachPresetCurves( int $history,
  68.                                 int $rpo,
  69.                                 string $curves[],
  70.                                 string $results[] )
  71. {
  72.     global int $gSelectNurbsCurvesBit;
  73.  
  74.     string $cmd = "detachCurve" + " -ch " + $history + " -cos on" +
  75.         " -rpo " + $rpo + " ";
  76.  
  77.     string $results[];
  78.     string $detachResults[];
  79.  
  80.     // for each string returned from groupObjectsByName, execute the command
  81.     // So if the active list is: curve1.u[0.3] curve2.u[0.5] curve1.u[0.6]
  82.     // these commands will be executed:
  83.     //   detachCurve <flags> curve1.u[0.3] curve1.u[0.6];
  84.     //   detachCurve <flags> curve2.u[0.5];
  85.     //
  86.     string $groupStrings[];
  87.     $groupStrings = groupObjectsByName( $curves, "\\." );
  88.     int $numStrings = size( $groupStrings );
  89.  
  90.     for( $i = 0; $i < $numStrings; $i ++ ) {
  91.         // execute $cmd + names of curves
  92.         if( catch( $detachResults = evalEcho( $cmd + $groupStrings[$i] ))) {
  93.             warning(" Problem evaluating detach command: " + $cmd + $groupStrings[$i]);
  94.         }
  95.         else {
  96.             int $j;
  97.             int $numResults = size( $results );
  98.             int $numDetachResults = size( $detachResults );
  99.             for( $j = 0; $j < $numDetachResults; $j ++, $numResults ++ ) {
  100.                 $results[$numResults] = $detachResults[$j];
  101.             }
  102.         }
  103.     }
  104.  
  105.     if( 0 == size($results) ) {
  106.         error ("Detach: failed on the input curves.");
  107.     }
  108. }
  109.  
  110. global proc performDetachPreset( int $history, int $rpo )
  111. {
  112.     // Get a list of each type of acceptable object type
  113.     // curves, and curves-on-surface.
  114.     //
  115.     global int $gSelectCurveParmPointsBit;
  116.     global int $gSelectEditPointsBit;
  117.     global int $gSelectIsoparmsBit;
  118.     string $curves[] = `filterExpand -ex true -sm $gSelectCurveParmPointsBit -sm $gSelectEditPointsBit`;
  119.     string $surfaces[] = `filterExpand -ex true -sm $gSelectIsoparmsBit`;
  120.  
  121.     if( (0 == size($curves)) && (0 == size($surfaces)) ) {
  122.         error ("Detach: Select point on curve or isoparm " +
  123.                "on surface to do detach.");
  124.         return;
  125.     }
  126.  
  127.     int $doHilite = `shouldHiliteAfterCompute`;
  128.  
  129.     string $crvRes[], $srfRes[];
  130.     if( size($curves) > 0 ) {
  131.         performDetachPresetCurves( $history, $rpo, $curves, $crvRes );
  132.     }
  133.     if( size($surfaces) > 0 ) {
  134.         performDetachPresetSurfaces( $history, $rpo, $surfaces, $srfRes );
  135.     }
  136.  
  137.     if( (size($srfRes) + size($crvRes)) > 0 ) {
  138.         int $n;
  139.         string $select = "select ";
  140.  
  141.         $n = size($crvRes);
  142.         for( $i=0; $i<$n; $i ++ ) {
  143.             $select = $select + $crvRes[$i] + " ";
  144.         }
  145.  
  146.         $n = size($srfRes);
  147.         for( $i=0; $i<$n; $i ++ ) {
  148.             $select = $select + $srfRes[$i] + " ";
  149.         }
  150.         select -cl;
  151.         if( $doHilite ) $select += ";hilite;";
  152.  
  153.         eval( $select );
  154.     }
  155. }
  156.